package com.example.wzh.robotsdemo;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * Created by WZH on 2017/9/7.
 */

public class SpUtils {


        private static String ProjectName = "ProjectName";

        public static void putString(Context ctx, String key, String value) {
            getEditor(ctx).putString(key, value).commit();
        }

        public static String getString(Context ctx, String key) {
            SharedPreferences sp = ctx.getSharedPreferences(ProjectName, Context.MODE_PRIVATE);
            return sp == null ? sp.getString(key, " ") : " ";
        }


        public static SharedPreferences.Editor getEditor(Context ctx) {
            SharedPreferences sp = ctx.getSharedPreferences(ProjectName, Context.MODE_PRIVATE);
            return sp.edit();
        }


}
